$(document).ready(function(){
            
    var wilddogRef = new Wilddog("https://mooji-sitechat.wilddogio.com");
    var wilddogRefChats = wilddogRef.child('chats');
    
    $('form').submit(function(){
        wilddogRefChats.push($('#m').val()).onDisconnect().remove();
        $('#m').val('');
        return false;
    });
    
    wilddogRefChats.on('child_added', function(snapshot) {
        $('#messages').append($('<li>').text(snapshot.val()));
    });
            
});